import requests
import json
import sys
# 目标URL
url = 'http://168.17.100.15:1025/generate'

if len(sys.argv)<2:
  print("    请输入prompt描述")
  sys.exit()
  #args="My name is Oliviver and I"
#arg = sys.argv[1]
#print(len(arg))
#print(len(sys.argv))
#print(sys.argv[1])
json_data={
"prompt":sys.argv[1],
"max_tokens":512,
"repetition_penalty":1.03,
"presence_penalty":1.2,
"frequency_penalty":1.2,
"temperature":0.5,
"top_k":10,
"top_p":0.95,
"stream":False
}

# 发送POST请求
response = requests.post(url, json=json_data)

# 打印响应内容
#print('Status Code:', response.status_code)
#print('Response Text:', response.text)


context = response.text 
context=json.loads(context)
#print(type(context))
#print(context)

context=context["text"][0]

#context="".json(context)
#print(type(context))
#print(context)
print("\n\n")
sys.stdout.write(context + '\n')
